<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>登录</title>
  <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
  <meta content="yes" name="apple-mobile-web-app-capable"/>
  <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
  <meta content="telephone=no" name="format-detection"/>
  <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  <script src="__STATIC__/layer/layer.js"></script>
</head>
<body>
    <form action="javascript:;" method="post" >
        手机号：<input type="text" name="mobile" value="{$login_mobile}"><br/>
        密码：<input type="password" name="password" value="{$login_pass}"><br/>
        <input type="button" value="提交" onclick="checkform();">
        <input type="checkbox" name="remember" value="1" {if condition="$remember eq 1"} checked {/if}>记住密码
        <a href="{:url('Login/find_password')}">忘记密码</a>

    </form>
    <a href="#">注册</a>
</body>
</html>
<script>
    /**
     * 检查提交的表单信息
     */
    function checkform(){
        var reg = /^1[34578]\d{9}$/;
        var mobile = $('input[name=mobile]').val();
        var password = $('input[name=password]').val();
        var remember = $('input[name=remember]:checked').val();
        if(mobile == ''){
            alert('请输入手机号');
            return false;
        }
        if(!reg.test(mobile)){
            alert('手机格式错误，请重新调填写');
            return false;
        }
        if(password == ''){
            alert('请输入登录密码');
            return false;
        }

        $.post("{:url('Login/loginin')}",
            {mobile:mobile,password:password,remember:remember},
            function(data){
                if(data.code == 1){
                    alert('登陆成功');
                    window.location.href = "{$url}";
                }else{
                    alert(data.msg);
//                    window.location.href = "{$url}";
                }
            }
        );
    }
</script>